#!/usr/bin/env bash

function abspath {
    cd "$(dirname "$1")"
    printf "%s/\n" "$(pwd)"
}

echo "Installing to path"
SOURCE_LINE="export EXPOSE_PATH=\"$(abspath ./)\"; export PATH=\$PATH:\$EXPOSE_PATH #EXPOSE_ENTRY"
echo ${SOURCE_LINE}

echo "Cleaning previous installations"
./scripts/setup/cleanup_bashprofile ~/.bashrc
./scripts/setup/cleanup_bashprofile ~/.bash_profile
./scripts/setup/cleanup_bashprofile ~/.zshrc

if [ -f ~/.bashrc ]; then 
    echo "${SOURCE_LINE}" >> ~/.bashrc
fi

if [ -f ~/.bash_profile ]; then
    echo "${SOURCE_LINE}" >> ~/.bash_profile
fi

if [ -f ~/.zshrc ]; then
    echo "${SOURCE_LINE}" >> ~/.zshrc
fi
